/**
 * Created by thinkl on 2017/6/22.
 */
$(function () {
    var app_data = {
        person: '',
        phone: '',
        add_province: '',
        add_city: '',
        add_district: '',
        add_detail: '',
    };
    var app = new Vue({
        el: '#create_address',
        data: app_data,
        methods: {
            add_save: function () {
                if (!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(app_data.phone))) {
                    alert("不是完整的11位手机号或者正确的手机号前七位");
                    return false;
                }
                $.post('/address/create_address', {
                    name: app_data.person,
                    phone: app_data.phone,
                    add_province: app_data.add_province,
                    add_city: app_data.add_city,
                    add_district: app_data.add_district,
                    add_detail: app_data.add_detail,
                    add_is_default: app_data.add_is_default
                }, function (data) {
                    var l = JSON.parse(data);
                    if (l.success) {
                        var order_id = getQueryString('order_id');
                        location.href = '/static/address_list/address_list.html?order_id=' + order_id
                    }
                })
            }
        }
    })
});
